#include <catch2/catch.hpp>

#include <limits>
#include "solution.hpp"

using namespace solution_084;

TEST_CASE("84. Largest Rectangle in Histogram", "[084]") {

SECTION("example 1") {
    std::vector heights{2,1,5,6,2,3};
    CHECK(Solution().largestRectangleArea(heights) == 10);
    CHECK(Solution().largestRectangleAreaBF(heights) == 10);
}

SECTION("example 2") {
    std::vector heights{3,2,1};
    CHECK(Solution().largestRectangleArea(heights) == 4);
    CHECK(Solution().largestRectangleAreaBF(heights) == 4);
}

SECTION("example 3") {
    std::vector heights{0,0,1,0,0,0};
    CHECK(Solution().largestRectangleArea(heights) == 1);
    CHECK(Solution().largestRectangleAreaBF(heights) == 1);
}

SECTION("example 4") {
    std::vector heights{1,2,2};
    CHECK(Solution().largestRectangleArea(heights) == 4);
    CHECK(Solution().largestRectangleAreaBF(heights) == 4);
}

SECTION("example 5") {
    std::vector<int> heights{0,std::numeric_limits<int>::max(),1};
    CHECK(Solution().largestRectangleArea(heights) == std::numeric_limits<int>::max());
    CHECK(Solution().largestRectangleAreaBF(heights) == std::numeric_limits<int>::max());
}

SECTION("example 6") {
    std::vector<int> heights;
    for (int i = 0; i < 20000; ++i)
        heights.push_back(i);
    CHECK(Solution().largestRectangleArea(heights) == 100000000);
    CHECK(Solution().largestRectangleAreaBF(heights) == 100000000);
}

}
